<script setup>
import { 
  Search, 
  Delete, 
  FolderAdd, 
  EditPen, 
  Check, 
  Close,
  Collection
} from '@element-plus/icons-vue'
// import { ElCol, ElRow } from 'element-plus'

</script>

<template>
  <el-row style="flex-direction: row;width:50vw">
    <el-col :span="6">
      <el-button>文本检索</el-button>
    </el-col>
    <el-col :span="6">
      <el-button>数据读取</el-button>
    </el-col>
  </el-row>
  <div class="list">
    <div class="title">
      RDAT-历史会话 
      <el-button 
      type="success" :icon="FolderAdd" 
      @click="newTopic()" plain> 新 建 +</el-button>
    </div>
    <div class="search">
      <el-input
        v-model="searchLine"
        placeholder="请搜索历史"
        :prefix-icon="Search"
        @input = "filterTopics"
      />
    </div>
    <div class="scroll">
      <el-scrollbar>
        <div class="scroll-content">
          <div
            v-for="topic in topicListShow"
            :key="topic.comm_guid"
            class="box"    
            :class="topic == rdatStore.topic? 'selected' : 'unselected'"
            @mouseover="topic.hover = true"
            @mouseleave="topic.hover = false"
          >
            <div 
              class="item" 
              @click.self="selectTopic(topic)"    
              v-show="!topic.editing"
            >
              {{ topic.title }}
            </div>
            <el-icon class="upd-btn" v-show="topic.hover && !topic.editing" @click.stop="updateTopic(topic)">
              <EditPen color="#c0bf94" />
            </el-icon>
            <el-icon class="del-btn" v-show="topic.hover && !topic.editing" @click.stop="deleteTopic(topic)">
              <Delete color="#f56c6c" />
            </el-icon>
            <span v-show="!topic.hover && !topic.editing">
              {{ formatTime(topic.update_time) }}
            </span>
            <div class="box" v-show="topic.editing">
              <el-input class="item ipt-bar"
                v-model="topic.newTitle"
                :prefix-icon="Collection"
              />          
              <el-icon class="chk-btn" @click.stop="confirmUpdate(topic)">
                <Check color="green"/>
              </el-icon>
              <el-icon class="cls-btn" @click.stop="cancelUpdate(topic)">
                <Close color="red"/>
              </el-icon>
            </div>
          </div>
       </div>
      </el-scrollbar>
    </div>
  </div>
  </template>



